package com.yyy.dm.consumer.service;

import com.yyy.dm.CommonResponse;
import com.yyy.dm.VoUtil;
import com.yyy.dm.base.CityDTO;
import com.yyy.dm.base.DmArea;
import com.yyy.dm.dao.AreaMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class AreaConsumerService {

    @Resource
    private AreaMapper areaMapper;


    public CommonResponse queryCity(){
//        return areaConsumerService.queryCity();
        List<DmArea> areaList = areaMapper.selectList(null);
        List<CityDTO> cityDTOList = new ArrayList<>();
        for (DmArea dmArea : areaList) {
            CityDTO cityDTO = new CityDTO();
            BeanUtils.copyProperties(dmArea,cityDTO);
            cityDTOList.add(cityDTO);
        }
        return VoUtil.returnSuccess(cityDTOList);
    }
}
